package com.ruoyi.common.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;


import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.ruoyi.common.domain.TrainingInstitutionInfomation;
import com.ruoyi.common.service.ITrainingInstitutionInfomationService;


/**
 * 培训机构基本信息Controller
 * 
 * @author wusihao
 * @date 2023-03-27
 */
@CrossOrigin
@RestController
@RequestMapping("/common/infomation")
public class TrainingInstitutionInfomationController extends BaseController
{
    @Autowired
    private ITrainingInstitutionInfomationService trainingInstitutionInfomationService;

    /**
     * 查询培训机构基本信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TrainingInstitutionInfomation trainingInstitutionInfomation)
    {
        startPage();
        List<TrainingInstitutionInfomation> list = trainingInstitutionInfomationService.selectTrainingInstitutionpeixunjigouInfomationList(trainingInstitutionInfomation);
        return getDataTable(list);
    }

    /**
     * 导出培训机构基本信息列表
     */
    @Log(title = "培训机构基本信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TrainingInstitutionInfomation trainingInstitutionInfomation)
    {
        List<TrainingInstitutionInfomation> list = trainingInstitutionInfomationService.selectTrainingInstitutionpeixunjigouInfomationList(trainingInstitutionInfomation);
        ExcelUtil<TrainingInstitutionInfomation> util = new ExcelUtil<TrainingInstitutionInfomation>(TrainingInstitutionInfomation.class);
        util.exportExcel(response, list, "培训机构基本信息数据");
    }

    /**
     * 获取培训机构基本信息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(trainingInstitutionInfomationService.selectTrainingInstitutionInfomationById(id));
    }

    /**
     * 新增培训机构基本信息
     */
    @Log(title = "培训机构基本信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TrainingInstitutionInfomation trainingInstitutionInfomation)
    {
        return toAjax(trainingInstitutionInfomationService.insertTrainingInstitutionInfomation(trainingInstitutionInfomation));
    }

    /**
     * 修改培训机构基本信息
     */
    @Log(title = "培训机构基本信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TrainingInstitutionInfomation trainingInstitutionInfomation)
    {
        return toAjax(trainingInstitutionInfomationService.updateTrainingInstitutionInfomation(trainingInstitutionInfomation));
    }

    /**
     * 删除培训机构基本信息
     */
    @Log(title = "培训机构基本信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(trainingInstitutionInfomationService.deleteTrainingInstitutionInfomationByIds(ids));
    }
}
